﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Tomato.Maths
{
    public class RandomValue
    {
        public double Probability { get; set; }

        public long LastHitIndex { get; set; }

        public int Interval { get; set; }

        public double Deviation { get; set; }

        public long NextHitIndex
        {
            get { return LastHitIndex + Interval; }
        }

        public void ComputeNextInterval(double random)
        { 
            int normalMean = (int)(1.0 / Probability);
            Interval = (int)(Interval < normalMean ? normalMean * (1 + random * Deviation) : normalMean * (1 - random * Deviation));
        }
    }
}
